#ifndef LOCATION_MSFSF_CONFIG_HPP
#define LOCATION_MSFSF_CONFIG_HPP

#include <commons/impl/noncopyable.hpp>
#include <commons/type/ret.hpp>
#include <nlohmann/json.hpp>

#include <string>
#include <mutex>
#include <memory>

namespace sros
{
    class File;
}

class Config : sros::impl::noncopyable
{
public:
    struct Cfg
    {
        bool enable = false;
        NLOHMANN_DEFINE_TYPE_INTRUSIVE(Cfg, enable)
    };

    static Config &ins();
    
    sros::RetBool init(const std::string &filename);
    
    sros::RetBool load(Cfg &cfg);
    
    sros::RetBool save(const Cfg &cfg);
    
private:
    Config() = default;
    
private:
    std::mutex mtx_;
    std::shared_ptr<sros::File> file_ = nullptr;
};

#endif

